<?php

namespace App\Admin\Actions\Post;

use App\Models\UserInfo;
use Dcat\Admin\Grid;
use Dcat\Admin\Grid\LazyRenderable;

class UserInfoSmall extends LazyRenderable
{
    public function grid(): Grid
    {
        // 获取外部传递的参数
        return Grid::make(new UserInfo(), function (Grid $grid) {
            $grid->column('id');
            $grid->column('nickName', '用户昵称');
            //$grid->column('goods_type')->display(function ($e) {
            //	$data = GoodsType::where('id', $this->goods_type)->pluck('name');
            //	return $data[0];
            //});
            $grid->column('created_at');
            $grid->column('updated_at');
            // 指定行选择器选中时显示的值的字段名称
            // 指定行选择器选中时显示的值的字段名称
            // 指定行选择器选中时显示的值的字段名称
            // 如果表格数据中带有 “name”、“title”或“username”字段，则可以不用设置
            $grid->rowSelector()->titleColumn('nickName');
            $grid->paginate(9);
            $grid->disableActions();
            $grid->filter(function (Grid\Filter $filter) {
                $filter->like('id')->width(4);
                $filter->like('nickName')->width(4);
            });
        });

    }
}